package com.demo.controller;


import com.demo.entity.VteRiskScoreItem;
import com.demo.entity.VteTabooScoreItem;
import com.demo.response.Result;
import com.demo.service.IVteTabooScoreItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * VTE预防禁忌评论项 前端控制器
 *
 * @author zm
 * @since 2020-11-25
 */
@RestController
@Api(tags = "VTE预防禁忌评论项")
@RequestMapping("/vteTabooScoreItem")
public class VteTabooScoreItemController {
    @Autowired
    IVteTabooScoreItemService iVteTabooScoreItemService;

    @ApiOperation("新增VTE预防禁忌")
    @PostMapping("/addVteTabooScoreItem")
    public Result addVteTabooScoreItem(@Validated @RequestBody VteTabooScoreItem vteRiskScoreItem, BindingResult result) {
        if (result.hasErrors()) {
            return Result.error(result.getFieldError().getDefaultMessage());
        }
        return iVteTabooScoreItemService.addVteTabooScoreItem(vteRiskScoreItem);
    }

    @ApiOperation("更新VTE预防禁忌")
    @PostMapping("/updateVteTabooScoreItem")
    public Result updateVteTabooScoreItem(@RequestBody VteTabooScoreItem vteRiskScoreItem, BindingResult result) {
        if (result.hasErrors()) {
            return Result.error(result.getFieldError().getDefaultMessage());
        }
        return iVteTabooScoreItemService.updateVteTabooScoreItem(vteRiskScoreItem);
    }

    @ApiOperation("删除VTE预防禁忌")
    @GetMapping("/deleteVteTabooScoreItem")
    public Result deleteVteTabooScoreItem(@RequestParam(name = "vteItemId") Integer vteItemId,
                                          @RequestParam(name = "deletedUserId") Integer deletedUserId) {
        return iVteTabooScoreItemService.deleteVteTabooScoreItem(vteItemId, deletedUserId);
    }

    @ApiOperation("VTE预防禁忌列表")
    @GetMapping("/vteTabooScoreItemList")
    public Result vteTabooScoreItemList(@RequestParam(name = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
                                        @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize,
                                        @RequestParam(name = "vteItemName", required = false) String vteItemName,
                                        @RequestParam(name = "vtePreventiveId", required = false) Integer vtePreventiveId,
                                        @RequestParam(name = "allItem", required = false, defaultValue = "false") Boolean allItem) {
        return iVteTabooScoreItemService.vteTabooScoreItemList(pageNumber, pageSize, vteItemName, vtePreventiveId, allItem);
    }


}
